
from selenium import webdriver
import time
drive=webdriver.Chrome()
drive.get('http://www.google.com')
# drive.find_element_by_id("skiplink").click()  ###有点问题
# drive.find_element_by_name('q').send_keys('inty youtube\n')

# #根据标签打开网页中的一个链接
# drive.find_element_by_link_text('Gmail').click()
# #返回
# drive.back()
# #根据部分标签打开网页中的一个链接
# drive.find_element_by_partial_link_text('il').click()

#使用tag name定位
# elments = drive.find_elements_by_tag_name('a')
# print(elments)

#elements定位
# for elment in elments:  #elements是list因此可以使用for循环
#     # print(elment)
#     print(elment.text)
#     if'视频'in elment.text:
#         elment.click()
#class定位

# drive.find_element_by_class_name('mnav c-font-normal c-color-t').click()

#Xpath定位   浏览器插件chropath
# drive.get('http://www.google.com')
#drive.find_element_by_xpath("//a[contains(text(),'Gmail')]").click()

#css selector定位
# drive.get('http://www.baidu.com')
# drive.find_element_by_css_selector('#kw').send_keys('inty youtube\n')


# time.sleep(5)#停5秒钟

# drive.quit()






"""浏览器互动"""
#open the url
# drive.get('hhtp://baidu.com')

#maximize the browser最大化
# drive.maximize_window()

#get title
# baidutitle=drive.title
# print(baidutitle)

#get current url
# currenturl=drive.current_url
# print(currenturl)

#Browser Refresh
#drive.refresh()

#Open another Url
#drive.get("http://google.com")

#Browser back
#drive.back()

#Browser Forward
#drive.forward()

#Get page Source
#pageSource = drive.page_source
#print(pageSource)

"""HTML<sele>Tag"""    #浏览器插件 selocity
# drive.get('http://www.timeanddate.com/')
# selectElements = drive.find_element_by_id('month')
#
# mouth = Select(selectElements)

#截图
# drive.save_screenshot('截图.png')
# drive.close()








